﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using ProxyHero.TabPages;

namespace ProxyHero.Common
{
    public class MsgBox
    {
        public MsgBox()
        { }

        public static DialogResult ShowMessage(string msg)
        {
            return MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        public static DialogResult ShowErrorMessage(string msg)
        {
            return MessageBox.Show(msg, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        public static DialogResult ShowExceptionMessage(Exception ex)
        {
            MsgBox msg = new MsgBox();
            return msg.ShowThreadExceptionDialog(ex);
        }

        public static DialogResult ShowQuestionMessage(string msg)
        {
           return  MessageBox.Show(msg, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
        }

        private DialogResult ShowThreadExceptionDialog(Exception ex)
        {
            string errorMessage = "错误信息：\n" +
                ex.Message + "\n" + ex.GetType() +
                "\nStack Trace:\n" +
                ex.StackTrace;
            frmException infoform = new frmException(errorMessage);
            return infoform.ShowDialog();
        }
    }
}
